<?php


class Zend_View_Helper_NavigationVisible extends Zend_View_Helper_Abstract {
	public function navigationVisible($beginIndex=-1, $endIndex=-1) {
		$container = $this->view->navigation()->getContainer();
		
		if ($beginIndex==-1) {
			$beginIndex = 0;
		}
		
		if ($endIndex == -1) {
			$endIndex = $container->count();
		}
		
		if ($beginIndex < 0 || $endIndex > $container->count() || $beginIndex >= $endIndex) {
			throw new Exception("Invalid index for the navigation - beginIndex: ".$beginIndex.", endIndex: ".$endIndex.", nbPages: ".$container->count());
		}
		
		$index = 0;
		foreach ($this->view->navigation()->getContainer()->getPages() as $page) {
			if ($index >= $beginIndex && $index < $endIndex) {
				$page->setVisible(true);
			}
			else {
				$page->setVisible(false);
			}
			$index++;
		}
	}
}
